/*
 * =====================================================================================
 *
 *       Filename:  create_new_password_2.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  03/02/2018 05:41:28 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *   Organization:  
 *
 * =====================================================================================
 */
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int create_new_random_pwd(std::string& password)
{
    char pwd_str[57] = "abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
    char rand_str[4] = "";

    std::random_shuffle(pwd_str, pwd_str + 57 - 1);                                                                                                                                                  

    for (int i = 0; i < 4; ++i) 
    {    
        rand_str[i] = pwd_str[i];
    }    

    password = rand_str;
    return 0;
}

int main()
{
    std::string password;
    srand(time(0));
    for (int i = 0; i < 100; ++i)
    {
        create_new_random_pwd(password);
        printf("%s\n", password.c_str());
    }
    return 0;
}

